-
-
Notifications
You must be signed in to change notification settings - Fork 33.3k
gh-58038: Unicode*Error: update args tuple on call
#139274
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it's very likely that people are relying on this at this point.
| 'start' : 0, 'reason' : 'ordinal not in range'}), | ||
| (UnicodeDecodeError, ('ascii', bytearray(b'\xff'), 0, 1, | ||
| 'ordinal not in range'), {}, | ||
| {'args' : ('ascii', bytearray(b'\xff'), 0, 1, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is setting off some alarm bells for me. If we're changing tests like this, we're probably breaking something.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This seems like a bug fix, there is a mismatch:
>>> exc = UnicodeDecodeError('ascii', bytearray(b'\xff'), 0, 1,'ordinal not in range')
>>> exc.args # 1 is the object
('ascii', bytearray(b'\xff'), 0, 1, 'ordinal not in range')
>>> exc.object
b'\xff'
>>>
|
A Python core developer has requested some changes be made to your pull request before we can consider merging it. If you could please address their requests along with any other requests in other reviews from core developers that would be appreciated. Once you have made the requested changes, please leave a comment on this pull request containing the phrase |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Don't change this. People might rely on this behavior and I didn't want to change this (see also #58038 (comment)).
In general .args contains the arguments that were passed at construction time. The same holds for other exceptions: https://docs.python.org/3/library/exceptions.html#BaseException.args.
|
Closed the issue. |
Well, the number of 3rd party codecs should be pretty low, and this change is a backward incompatible change on purpose: it fixes an old bug. |
|
But it is not the documented behavior (or this should be re-documented for UnicodeError explicitly, or maybe it is documented elsewhere and I didn't find it (I am no more on my dev session)). Users should rely on the non-args value and instead access the named properties I think. |
I agree with that. But it doesn't prevent to fix args is not documented explicitly in UnicodeError: https://docs.python.org/dev/library/exceptions.html#UnicodeError It's documented on the BaseException: https://docs.python.org/dev/library/exceptions.html#BaseException.args |
|
Yes, but the fact that it says:
makes me feel that we should not break this part of the contract. That is, OTOH, we could have maybe have an
So, re-using the same exception object should be allowed. Thus, I wouldn't consider the current behavior an "old" bug. Note that a similar argument could be said for |
Uh oh!
There was an error while loading. Please reload this page.